import api from './axios';

/**
 * 用户相关的API服务
 */
const userService = {
  /**
   * 获取当前用户信息
   * @returns {Promise} - 返回用户信息
   */
  getCurrentUser: async () => {
    return api.get('/users/current');
  },

  /**
   * 更新用户配置
   * @param {Object} settings - 用户配置
   * @returns {Promise} - 返回更新结果
   */
  updateSettings: async (settings) => {
    return api.put('/users/settings', settings);
  },

  /**
   * 更新用户头像
   * @param {FormData} formData - 包含头像文件的表单数据
   * @returns {Promise} - 返回更新结果
   */
  updateAvatar: async (formData) => {
    return api.post('/users/avatar', formData, {
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    });
  },

  /**
   * 修改密码
   * @param {Object} passwordData - 包含旧密码和新密码的对象
   * @returns {Promise} - 返回修改结果
   */
  changePassword: async (passwordData) => {
    return api.post('/users/change-password', passwordData);
  },

  /**
   * 获取用户通知设置
   * @returns {Promise} - 返回通知设置
   */
  getNotificationSettings: async () => {
    return api.get('/users/notification-settings');
  },

  /**
   * 更新通知设置
   * @param {Object} notificationSettings - 通知设置
   * @returns {Promise} - 返回更新结果
   */
  updateNotificationSettings: async (notificationSettings) => {
    return api.put('/users/notification-settings', notificationSettings);
  },

  /**
   * 获取隐私设置
   * @returns {Promise} - 返回隐私设置
   */
  getPrivacySettings: async () => {
    return api.get('/users/privacy-settings');
  },

  /**
   * 更新隐私设置
   * @param {Object} privacySettings - 隐私设置
   * @returns {Promise} - 返回更新结果
   */
  updatePrivacySettings: async (privacySettings) => {
    return api.put('/users/privacy-settings', privacySettings);
  }
};

export default userService; 